package LB2;

import static java.lang.Math.cos;
import static java.lang.Math.sin;
/**
 * Created with IntelliJ IDEA.
 * User: Борис
 * Date: 14.10.13
 * Time: 19:39
 * To change this template use File | Settings | File Templates.
 */
public class CalculateSin {
    private double[] interval;
    public CalculateSin(double[] interval){
        this.interval = interval;
    }
    public double[][] getValuesGridFunction(){
        int size = interval.length;
        double[][] result = new double[2][size];
        for(int i = 0; i<size; i++){
            result[0][i] = interval[i];
            result[1][i] = sin(interval[i]);
        }
        return result;
    }
    // вычисляет значение sin'(x) в каждой точки сетки
    public double[][] firstDiffSin(){
        int size = interval.length;
        double[][] result = new double[2][size];
        for(int i = 0; i<size; i++){
            result[0][i] = interval[i];
            result[1][i] = cos(interval[i]);
        }
        return result;
    }
    // вычисляет значение sin''(x) в каждой точки сетки
    public double[][] secondDiffSin(){
        int size = interval.length;
        double[][] result = new double[2][size];
        for(int i = 0; i<size; i++){
            result[0][i] = interval[i];
            result[1][i] = -sin(interval[i]);
        }
        return result;
    }
}
